package net.bluemind.unixsocket.impl;

import java.nio.ByteBuffer;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.ptr.IntByReference;

/**
 * Low level GLibC binding suitable for JNA
 * 
 * @author tom
 *
 */
public interface GLibcSocket extends Library {

	public static final GLibcSocket INSTANCE = (GLibcSocket) Native
			.loadLibrary("c", GLibcSocket.class);

	public static final short AF_UNIX = 1;
	public static final short SOCK_STREAM = 1;

	int socket(int domain, int type, int protocol);

	int connect(int s, sockaddr_un name, int namelen);

	int bind(int s, sockaddr_un name, int namelen);

	int listen(int s, int backlog);

	int accept(int s, sockaddr_un addr, IntByReference addrlen);

	int recv(int s, ByteBuffer buf, int len, int flags);

	int send(int s, ByteBuffer msg, int len, int flags);

	int close(int s);

	String strerror(int errno);

}
